/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package tracker.android.com.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import tracker.android.com.BluetoothDevice;
import tracker.android.com.BluetoothService;
import tracker.android.com.ComPackage;
import tracker.android.com.IDevice;
import tracker.android.com.ISocket;
import tracker.android.com.State;
import tracker.android.nativelib.BluetoothAdaptor;
import tracker.android.nativelib.BluetoothSocket;
import tracker.android.nativelib.Context;
import tracker.android.nativelib.Handler;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Bluetooth Service</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link tracker.android.com.impl.BluetoothServiceImpl#getNAME <em>NAME</em>}</li>
 *   <li>{@link tracker.android.com.impl.BluetoothServiceImpl#getTAG <em>TAG</em>}</li>
 *   <li>{@link tracker.android.com.impl.BluetoothServiceImpl#getMAdaptor <em>MAdaptor</em>}</li>
 *   <li>{@link tracker.android.com.impl.BluetoothServiceImpl#getMHandler <em>MHandler</em>}</li>
 *   <li>{@link tracker.android.com.impl.BluetoothServiceImpl#getMState <em>MState</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class BluetoothServiceImpl extends EObjectImpl implements BluetoothService {
	/**
	 * The default value of the '{@link #getNAME() <em>NAME</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNAME()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;
	/**
	 * The cached value of the '{@link #getNAME() <em>NAME</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNAME()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;
	/**
	 * The default value of the '{@link #getTAG() <em>TAG</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTAG()
	 * @generated
	 * @ordered
	 */
	protected static final String TAG_EDEFAULT = null;
	/**
	 * The cached value of the '{@link #getTAG() <em>TAG</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTAG()
	 * @generated
	 * @ordered
	 */
	protected String tag = TAG_EDEFAULT;
	/**
	 * The cached value of the '{@link #getMAdaptor() <em>MAdaptor</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMAdaptor()
	 * @generated
	 * @ordered
	 */
	protected BluetoothAdaptor mAdaptor;
	/**
	 * The cached value of the '{@link #getMHandler() <em>MHandler</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMHandler()
	 * @generated
	 * @ordered
	 */
	protected Handler mHandler;
	/**
	 * The default value of the '{@link #getMState() <em>MState</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMState()
	 * @generated
	 * @ordered
	 */
	protected static final State MSTATE_EDEFAULT = State.NONE;
	/**
	 * The cached value of the '{@link #getMState() <em>MState</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMState()
	 * @generated
	 * @ordered
	 */
	protected State mState = MSTATE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BluetoothServiceImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ComPackage.Literals.BLUETOOTH_SERVICE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getNAME() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNAME(String newNAME) {
		String oldNAME = name;
		name = newNAME;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ComPackage.BLUETOOTH_SERVICE__NAME, oldNAME, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getTAG() {
		return tag;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTAG(String newTAG) {
		String oldTAG = tag;
		tag = newTAG;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ComPackage.BLUETOOTH_SERVICE__TAG, oldTAG, tag));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BluetoothAdaptor getMAdaptor() {
		if (mAdaptor != null && mAdaptor.eIsProxy()) {
			InternalEObject oldMAdaptor = (InternalEObject)mAdaptor;
			mAdaptor = (BluetoothAdaptor)eResolveProxy(oldMAdaptor);
			if (mAdaptor != oldMAdaptor) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ComPackage.BLUETOOTH_SERVICE__MADAPTOR, oldMAdaptor, mAdaptor));
			}
		}
		return mAdaptor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BluetoothAdaptor basicGetMAdaptor() {
		return mAdaptor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMAdaptor(BluetoothAdaptor newMAdaptor) {
		BluetoothAdaptor oldMAdaptor = mAdaptor;
		mAdaptor = newMAdaptor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ComPackage.BLUETOOTH_SERVICE__MADAPTOR, oldMAdaptor, mAdaptor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Handler getMHandler() {
		if (mHandler != null && mHandler.eIsProxy()) {
			InternalEObject oldMHandler = (InternalEObject)mHandler;
			mHandler = (Handler)eResolveProxy(oldMHandler);
			if (mHandler != oldMHandler) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ComPackage.BLUETOOTH_SERVICE__MHANDLER, oldMHandler, mHandler));
			}
		}
		return mHandler;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Handler basicGetMHandler() {
		return mHandler;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMHandler(Handler newMHandler) {
		Handler oldMHandler = mHandler;
		mHandler = newMHandler;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ComPackage.BLUETOOTH_SERVICE__MHANDLER, oldMHandler, mHandler));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public State getMState() {
		return mState;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMState(State newMState) {
		State oldMState = mState;
		mState = newMState == null ? MSTATE_EDEFAULT : newMState;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ComPackage.BLUETOOTH_SERVICE__MSTATE, oldMState, mState));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ISocket connect(IDevice device) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<IDevice> getDeviceList() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void BluetoothService(Context context, Handler handler) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void connect(BluetoothDevice device) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void connected(BluetoothSocket socket, BluetoothDevice device) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void start() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void stop() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getState() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void connectionFailed() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setState(int state) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void write(EList<Byte> out, int size) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void connectionLost() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void write(EList<Byte> out, int size, tracker.android.sens.Thread senderThread) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ComPackage.BLUETOOTH_SERVICE__NAME:
				return getNAME();
			case ComPackage.BLUETOOTH_SERVICE__TAG:
				return getTAG();
			case ComPackage.BLUETOOTH_SERVICE__MADAPTOR:
				if (resolve) return getMAdaptor();
				return basicGetMAdaptor();
			case ComPackage.BLUETOOTH_SERVICE__MHANDLER:
				if (resolve) return getMHandler();
				return basicGetMHandler();
			case ComPackage.BLUETOOTH_SERVICE__MSTATE:
				return getMState();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ComPackage.BLUETOOTH_SERVICE__NAME:
				setNAME((String)newValue);
				return;
			case ComPackage.BLUETOOTH_SERVICE__TAG:
				setTAG((String)newValue);
				return;
			case ComPackage.BLUETOOTH_SERVICE__MADAPTOR:
				setMAdaptor((BluetoothAdaptor)newValue);
				return;
			case ComPackage.BLUETOOTH_SERVICE__MHANDLER:
				setMHandler((Handler)newValue);
				return;
			case ComPackage.BLUETOOTH_SERVICE__MSTATE:
				setMState((State)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ComPackage.BLUETOOTH_SERVICE__NAME:
				setNAME(NAME_EDEFAULT);
				return;
			case ComPackage.BLUETOOTH_SERVICE__TAG:
				setTAG(TAG_EDEFAULT);
				return;
			case ComPackage.BLUETOOTH_SERVICE__MADAPTOR:
				setMAdaptor((BluetoothAdaptor)null);
				return;
			case ComPackage.BLUETOOTH_SERVICE__MHANDLER:
				setMHandler((Handler)null);
				return;
			case ComPackage.BLUETOOTH_SERVICE__MSTATE:
				setMState(MSTATE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ComPackage.BLUETOOTH_SERVICE__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case ComPackage.BLUETOOTH_SERVICE__TAG:
				return TAG_EDEFAULT == null ? tag != null : !TAG_EDEFAULT.equals(tag);
			case ComPackage.BLUETOOTH_SERVICE__MADAPTOR:
				return mAdaptor != null;
			case ComPackage.BLUETOOTH_SERVICE__MHANDLER:
				return mHandler != null;
			case ComPackage.BLUETOOTH_SERVICE__MSTATE:
				return mState != MSTATE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (NAME: ");
		result.append(name);
		result.append(", TAG: ");
		result.append(tag);
		result.append(", mState: ");
		result.append(mState);
		result.append(')');
		return result.toString();
	}

} //BluetoothServiceImpl
